home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpsons / Support / dlogdata / export.Dxr / 00003_scrollbar parent.ls < prev    next >
Encoding:
Text File  |  1996-08-16  |  2.4 KB  |  73 lines

  1. property scrollUpBtn, scrollDownBtn, scrollColumn, scrollThumb, scrollThumbRect, disableSprite, theScrollBarLength, theScrollBarTop, theScrollBarBottom, theThumbLength
  2. global theExportDialog
  3.  
  4. on birth me
  5.   set scrollColumn to 7
  6.   set scrollUpBtn to 8
  7.   set scrollDownBtn to 9
  8.   set scrollThumb to 10
  9.   set scrollThumbRect to 11
  10.   set disableSprite to 12
  11.   puppetSprites(scrollColumn, disableSprite, 1)
  12.   set theThumbLength to the width of sprite scrollThumb
  13.   set theScrollBarTop to the left of sprite scrollColumn
  14.   set theScrollBarBottom to the right of sprite scrollColumn
  15.   set theScrollBarLength to the width of sprite scrollColumn
  16.   return me
  17. end
  18.  
  19. on update me
  20.   set currentFileNumber to getCurrentFileNumber(theExportDialog)
  21.   set totalPositions to getTheNumberOfFiles(theExportDialog)
  22.   if currentFileNumber = 1 then
  23.     set the locH of sprite scrollThumb to theScrollBarTop + (theThumbLength / 2)
  24.   else
  25.     if currentFileNumber = totalPositions then
  26.       set the locH of sprite scrollThumb to theScrollBarBottom - (theThumbLength / 2)
  27.     else
  28.       set theIncrement to (theScrollBarLength - (theThumbLength * 2)) / (totalPositions - 1.0)
  29.       set theThumbPosition to (currentFileNumber - 1.0) * theIncrement
  30.       set the locH of sprite scrollThumb to theScrollBarTop + theThumbLength + theThumbPosition
  31.     end if
  32.   end if
  33.   set the locH of sprite scrollThumbRect to -1000
  34. end
  35.  
  36. on moveThumbRect me, theThumbPosition
  37.   set currentFileNumber to getCurrentFileNumber(theExportDialog)
  38.   set totalPositions to getTheNumberOfFiles(theExportDialog)
  39.   set theThumbPosition to theThumbPosition - theScrollBarTop
  40.   set theIncrement to theScrollBarLength / totalPositions
  41.   repeat with count = 1 to totalPositions
  42.     if theThumbPosition < (count * theIncrement) then
  43.       set theFilePosition to count
  44.       exit repeat
  45.     end if
  46.   end repeat
  47.   set theDirection to theFilePosition - currentFileNumber
  48.   update(theExportDialog, theDirection)
  49.   set the locH of sprite scrollThumbRect to -1000
  50. end
  51.  
  52. on disable me
  53.   set the locH of sprite disableSprite to 151
  54.   updateStage()
  55. end
  56.  
  57. on enable me
  58.   set the locH of sprite disableSprite to -1000
  59.   updateStage()
  60. end
  61.  
  62. on handleButton me, whichSprite
  63.   if hiliteButton(whichSprite) then
  64.     if whichSprite = scrollUpBtn then
  65.       decrementFilePointer(theExportDialog)
  66.     else
  67.       if whichSprite = scrollDownBtn then
  68.         incrementFilePointer(theExportDialog)
  69.       end if
  70.     end if
  71.   end if
  72. end
  73.